<?php
if(!isset($_GET['q']))
{
	header('refresh:0; url=register.php');
}
else
{
	include('include/session.php');
	$q=$_GET['q'];
	if ($q == 'new'){?>
<form action="process.php" method="post">
<fieldset>
  <legend>Organization Basic Information</legend>
  <ul>
    <li id="li_orgName">
      <label id="label_orgName" for="orgName">Organization Name<span class="description_label">(Required) <?php echo $form->error("orgName"); ?></span></label>
      <input id="orgName" type="text" name="orgName" size="30" maxlength="30" value="<?php echo $form->value("orgName"); ?>" />
      <span id="userInfo">Think Of A Username That At Least 4 Characters</span> </li>
    <li id="li_website">
      <label id="label_website" for="websiteAddress">Organization Website<span class="description_label"> <?php echo $form->error("websiteAddress"); ?></span></label>
      <input id="websiteAddress" size="40" type="text" name="websiteAddress" value="<?php echo $form->value("websiteAddress"); ?>" />
    </li>
    <li id="li_category">
      <label id="label_category" for="category">Category<span class="description_label">(Required) <?php echo $form->error("category"); ?></span></label>
      <select id="category" name="category">
        <option value="<?php echo $form->value("category"); ?>"></option>
        <option value="farm">Farm</option>
        <option value="farmers_market">Farmer's Market</option>
        <option value="community_garden">Community Garden</option>
        <option value="orchards">Orchards</option>
        <option value="csa" >CSA</option>
        <option value="other">Other</option>
      </select>
    </li>
  </ul>
</fieldset>
<fieldset>
  <legend>Organization Contact Information</legend>
  <ul>
    <li id="li_orgEmail">
      <label id="label_orgEmail" for="orgEmail">Email<span class="description_label">(Required) <?php echo $form->error("orgEmail"); ?></span></label>
      <input id="orgEmail" name="orgEmail" type="text" size="30" maxlength="255" value="<?php echo $form->value("orgEmail"); ?>" />
    </li>
    <li id="li_orgPhoneNumber">
      <label id="label_orgPhoneNumber" for="orgPhoneNumber">Phone<span class="description_label"> (###) ###-#### <?php echo $form->error("orgPhoneNumber"); ?></span></label>
      <input id="orgPhoneNumber" size="20" type="text" name="orgPhoneNumber" placeholder="(___) ___-____" value="<?php echo $form->value("orgPhoneNumber"); ?>" />
      <span id="orgPhoneNumberInfo">The Organization's Phone Number</span> </li>
    <li id="li_orgFaxNumber">
      <label id="label_orgFaxNumber" for="orgFaxNumber">Fax<span class="description_label"> (###) ###-#### <?php echo $form->error("orgFaxNumber"); ?></span></label>
      <input id="orgFaxNumber" size="20" type="text" name="orgFaxNumber" placeholder="(___) ___-____" value="<?php echo $form->value("orgFaxNumber"); ?>" />
      <span id="orgFaxNumberInfo">The Organization's Fax Number</span> </li>
    <!-- Address -->
    <li>
      <label id="label_streetAddress" for="streetAddress">Address<span class="description_label">(Required) <?php echo $form->error("streetAddress"); ?></span></label>
      <input id="streetAddress" placeholder="1234 Main Street" size="30" name="streetAddress" value="<?php echo $form->value("streetAddress"); ?>" type="text" />
      <br />
      <input id="streetAddress2" placeholder="suite 567" size="30"  name="streetAddress2" class="element text" value="<?php echo $form->value("streetAddress2"); ?>" type="text" />
      <br />
      <input id="city" name="city" placeholder="Los Angeles" size="20" value="<?php echo $form->value("city"); ?>" type="text" />
      <input id="state" name="state" placeholder="CA" size="5" value="<?php echo $form->value("state"); ?>" type="text">
      <input id="zipCode" name="zipCode" placeholder="91790" size="10" value="<?php echo $form->value("zipCode"); ?>" type="text" />
    </li>
  </ul>
</fieldset>
</form>
<!-- live typecasting -->
<script type="text/javascript" src="jscripts/jquery.js" ></script>
<script type="text/javascript" src="jscripts/jquery.maskedinput-1.3.js" ></script>
<script>
jQuery(function($){
   $("#orgPhoneNumber").mask("(###) ###-####");
   $("#orgFaxNumber").mask("(###) ###-####");
});
</script>
<?php 
	}else{
$req_org_info = $database->getOrgInfo($q);?>
<!--Orgnanization Name-->
<fieldset>
  <legend>Organization Basic Information</legend>
  <ul>
    <li id="li_orgName">
      <label id="label_orgName" for="orgName">Organization Name</label>
      <input id="orgName" type="text" name="orgName" size="30" maxlength="30" value="<?php echo $req_org_info['orgName'] ?>" disabled="disabled" />
    </li>
    <li id="li_website">
      <label id="label_website" for="websiteAddress">Organization Website</label>
      <input id="websiteAddress" size="40" type="text" name="websiteAddress" value="<?php echo $req_org_info['websiteAddress'] ?>" disabled="disabled" />
    </li>
    <li id="li_category">
      <label id="label_category" for="category">Category</label>
      <input class="element text"  type="text" size="30" disabled="disabled"  name="category" value="<?php
				switch($req_org_info['category']){
					case "other":
						echo "Other";
						break;
					case "farm":
						echo "Farm";
						break;
					case "farmers_market":
						echo "Farmer's Market";
						break;
					case "community_garden":
						echo "Community Garden";
						break;
					case "orchards":
						echo "Orchards";
						break;
					case "csa":
						echo "CSA";
						break;
				}?>"/>
    </li>
  </ul>
</fieldset>
<fieldset>
  <legend>Organization Contact Information</legend>
  <ul>
    <li id="li_orgEmail">
      <label id="label_orgEmail" for="orgEmail">Organization Email</label>
      <input id="orgEmail" name="orgEmail" type="text" size="30" maxlength="255" value="<?php echo $req_org_info['email'] ?>" disabled="disabled" />
    </li>
    <li id="li_orgPhoneNumber">
      <label id="label_orgPhoneNumber" for="orgPhoneNumber">Organization Phone Number</label>
      <input id="orgPhoneNumber" size="20" type="text" name="orgPhoneNumber" disabled="disabled" 
                    value="(<?php echo $req_org_info['areaCode'] ?>) <?php echo $req_org_info['prefix'] ?>-<?php echo $req_org_info['lineNumber'] ?>" />
    <li id="li_orgFaxNumber">
      <label id="label_orgFaxNumber" for="orgFaxNumber">Organization Fax Number</label>
      <input id="orgFaxNumber" size="20" type="text" name="orgFaxNumber" disabled="disabled" 
                    value="(<?php echo $req_org_info['faxAreaCode'] ?>) <?php echo $req_org_info['faxPrefix'] ?>-<?php echo $req_org_info['faxLineNumber'] ?>"/>
    <li>
      <label id="label_streetAddress" for="streetAddress">Organization Address</label>
      <input id="streetAddress" size="30" name="streetAddress" value="<?php echo $req_org_info['streetAddress'] ?>" type="text" disabled="disabled" />
      <br />
      <input id="streetAddress2" size="30"  name="streetAddress2" class="element text" value="<?php echo $req_org_info['streetAddress2'] ?>" type="text" disabled="disabled" />
      <br />
      <input id="city" name="city" size="20" value="<?php echo $req_org_info['city'] ?>" type="text" disabled="disabled" />
      <input id="state" name="state" size="5" value="<?php echo $req_org_info['state'] ?>" type="text" disabled="disabled" />
      <input id="zipCode" name="zipCode" size="10" value="<?php echo $req_org_info['zipCode'] ?>" type="text" disabled="disabled" />
    </li>
  </ul>
</fieldset>
<?php
	}
}?>
